package com.sfh.cpc.com.req;

import android.app.Application;

import com.sfh.cpc.com.BaseAppContent;
import com.sfh.cpc.com.entity.EUser;
import com.sfh.lib.AppCacheManager;
import com.sfh.lib.http.IRxHttpClient;
import com.sfh.lib.http.service.CommHttpClientService;
import com.sfh.lib.http.transaction.OutreachRequest;
import com.sfh.lib.utils.UtilTool;

import java.io.Reader;
import java.lang.reflect.Type;

/***
 * 基础请求对象
 * @param <T>
 */
public class ReqBase<T> extends OutreachRequest<T> {

    long userId;

    String mac;

    String verion;

    //android ios pc
    String type;

    public ReqBase(String path) {
        super(path);
    }

    @Override
    public IRxHttpClient getHttpService() {
        return CommHttpClientService.newInstance();
    }

    @Override
    public String getUrl(String code) {
        return BaseAppContent.getUrl();
    }

    @Override
    public Object buildParam() {
        this.type = "android";
        Application application = AppCacheManager.getApplication();
        this.mac = UtilTool.getMacDeviceId(application);
        this.verion = UtilTool.getVersionCode(application);
        EUser user = AppCacheManager.getCache(BaseAppContent.USER, EUser.class);
        if (user != null) {
            this.userId = user.getUserId();
        }
        return super.buildParam();
    }

    public long getUserId() {
        return userId;
    }
}
